#include "IIC.h"

#define AT24C02_ADDRESS 0xA0

void AT24C02_WriteByte(unsigned char WordAddress,Data)
{
    IIC_Start();
    IIC_SendByte(AT24C02_ADDRESS);
    IIC_ReceiveACK();
    IIC_SendByte(WordAddress);
    IIC_ReceiveACK();
    IIC_SendByte(Data);
    IIC_ReceiveACK();
    IIC_Stop();
}

unsigned char AT24C02_ReadByte(unsigned char WordAddress)
{
    unsigned char Data;
    IIC_Start();
    IIC_SendByte(AT24C02_ADDRESS);
    IIC_ReceiveACK();
    IIC_SendByte(WordAddress);
    IIC_ReceiveACK();
    IIC_Start();
    IIC_SendByte(AT24C02_ADDRESS|0x01);
    IIC_ReceiveACK();
    Data=IIC_ReceiveByte();    
    IIC_SendACK(1);
    IIC_Stop();
    return Data;
}